package com.lovegu.springmvc;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 老顾
 * @title: HelloController
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/9/25 15:46
 */
public class HelloController implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        //业务代码
        ModelAndView mv = new ModelAndView();
        mv.addObject("msg","HelloSpringMVC！");
        //视图解释
        mv.setViewName("text");//需要拼接的视图名称，参考视图解析器的代码实际地址就是（/WEB-INF/jsp/text.jsp）
        return mv;
    }
}
